:root {
  --box-padding: 20px;
  --shadow-color: rgba(129, 129, 129, 0.08);
  --max-width: 1440px;
  --primary-color: #409eff;
  --transition-duration: 0.2s;
  --base-margin: 8px;
  --tag-radius: 6px;
  --tag-padding: 8px 12px;
  --tag-gap: 8px;
  --tag-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --tag-hover-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  --tag-transition: 0.18s ease-out;
  --tag-scale: 1.02;
}

.library-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 10px 0;
  margin: 0;
  overflow: auto;

  >* {
    width: 100%;
    max-width: var(--max-width);
  }

  @media (max-width: 1024px) {
    --box-padding: 18px;
    padding: 18px;
  }

  @media (max-width: 768px) {
    --box-padding: 16px;
    padding: 16px;
  }

  @media (max-width: 480px) {
    --box-padding: 14px;
    padding: 14px;
  }
}

.library-tags {
  width: 100%;
  height: auto;
  min-height: 200px;
  max-height: 300px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: box-shadow var(--tag-transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;

  &:hover {
    box-shadow: var(--tag-hover-shadow);
  }

  .hot-tags-title {
    font-size: 16px;
    font-weight: 500;
    color: #606266;
    margin-bottom: var(--base-margin);
  }

  .hot-tags-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--tag-gap);
    width: 100%;
    flex: 1;
    min-height: 180px;
    padding: 16px;

    .hot-tag-item {
      cursor: pointer;
      border-radius: var(--tag-radius);
      padding: var(--tag-padding);
      box-shadow: var(--tag-shadow);
      transition: all var(--tag-transition);
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;

      &:hover {
        transform: scale(var(--tag-scale));
        box-shadow: var(--tag-hover-shadow);
      }

      &.is-active {
        background-color: var(--primary-color);
        color: white;
        box-shadow: 0 1px 4px rgba(64, 158, 255, 0.2);
      }
    }
  }

  @media (max-width: 1024px) {
    --tag-padding: 8px 12px;
    --tag-gap: 8px;
    --tag-scale: 1.01;
    --tag-hover-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    --scrollbar-width: 8px;
    --scrollbar-thumb-color: #c0c0c0;
    padding: 16px;

    .hot-tags-list {
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
  }

  @media (max-width: 768px) {
    --tag-padding: 6px 10px;
    --tag-gap: 6px;
    --tag-scale: 1;
    --tag-hover-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    --scrollbar-width: 6px;
    --scrollbar-thumb-color: #b0b0b0;
    padding: 12px;

    .hot-tags-list {
      grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
  }

  @media (max-width: 480px) {
    --tag-padding: 6px 8px;
    --tag-gap: 4px;
    --tag-scale: 1;
    --tag-hover-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 4px;
    --scrollbar-thumb-color: #a0a0a0;
    padding: 8px;

    .hot-tags-list {
      grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    .hot-tags-title {
      font-size: 14px;
    }
  }
}


.library-search {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  height: 18vh;
  max-height: 180px;
  min-height: 120px;
  margin: calc(var(--base-margin)* 2) 0;
  overflow: hidden;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  border-radius: 8px;
  transition: background 0.3s ease, box-shadow 0.3s ease;

  &:hover {
    background: linear-gradient(135deg, #f0f4f8 0%, #ffffff 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);

  &::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
  }

  &::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
    border-radius: var(--scrollbar-width);
  }

  &::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-color);
    border-radius: var(--scrollbar-width);
    border: 2px solid transparent;
    background-clip: content-box;
  }

  &::-webkit-scrollbar-corner {
    background: transparent;
  }

  @media (max-width: 1024px) {
    --scrollbar-width: 8px;
    --scrollbar-thumb-color: #c0c0c0;
  }

  @media (max-width: 768px) {
    --scrollbar-width: 6px;
    --scrollbar-thumb-color: #b0b0b0;
  }

  @media (max-width: 480px) {
    --scrollbar-width: 4px;
    --scrollbar-thumb-color: #a0a0a0;
  }

  .search-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;

    .search-input {
      width: 50%;
      position: relative;
      border: 1px solid rgba(64, 158, 255, 0.15);
      border-radius: 24px;
      background: white;
      transition: all 0.3s ease;
      transform-origin: center;
      box-shadow: 0 2px 6px rgba(64, 158, 255, 0.08);

      &:focus {
        border-color: rgba(64, 158, 255, 0.3);
        box-shadow: 0 2px 8px rgba(64, 158, 255, 0.15);
        transform: scale(1.01);
      }

      &:hover {
        border-color: rgba(64, 158, 255, 0.25);
        box-shadow: 0 2px 8px rgba(64, 158, 255, 0.12);
      }
    }

    .search-input:focus {
      outline: none;
    }

    @keyframes borderAnimation {
      0% {
        background: linear-gradient(white, white) padding-box,
          linear-gradient(90deg, #409eff, #67c23a, #e6a23c, #f56c6c) border-box;
      }

      25% {
        background: linear-gradient(white, white) padding-box,
          linear-gradient(120deg, #409eff, #67c23a, #e6a23c, #f56c6c) border-box;
      }

      50% {
        background: linear-gradient(white, white) padding-box,
          linear-gradient(180deg, #409eff, #67c23a, #e6a23c, #f56c6c) border-box;
      }

      75% {
        background: linear-gradient(white, white) padding-box,
          linear-gradient(240deg, #409eff, #67c23a, #e6a23c, #f56c6c) border-box;
      }

      100% {
        background: linear-gradient(white, white) padding-box,
          linear-gradient(90deg, #409eff, #67c23a, #e6a23c, #f56c6c) border-box;
      }
    }
  }

  .rsr-slot-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;

    .rsr-slot-box {
      width: 60%;
    }
  }

  @media (max-width: 1024px) {
    --input-width: 90%;
    --input-padding: 16px;
    --search-gap: 20px;
    --hover-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    --active-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 8px;
    --scrollbar-thumb-color: #c0c0c0;
    min-height: 120px;
  }

  @media (max-width: 768px) {
    --input-width: 100%;
    --input-padding: 12px;
    --search-gap: 16px;
    --hover-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --active-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 6px;
    --scrollbar-thumb-color: #b0b0b0;
    min-height: 100px;
  }

  @media (max-width: 480px) {
    --input-padding: 8px;
    --search-gap: 12px;
    --hover-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    --active-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 4px;
    --scrollbar-thumb-color: #a0a0a0;
    min-height: 80px;
    margin: var(--base-margin) 0;
  }
}

::v-deep .el-input__prefix {
  left: 12px;
  color: #909399;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;

  .svg-icon {
    width: 18px;
    height: 18px;
    transition: inherit;
  }

  &:hover {
    color: var(--primary-color);
    transform: scale(1.15);
    animation: iconBounce 0.4s ease;
  }

  &:active {
    transform: scale(0.95);
  }
}

@keyframes iconBounce {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}


.library-resources {
  --grid-gap: 24px;
  --card-padding: 16px;

  position: relative;
  display: flex;
  flex-direction: column;
  height: 45vh;
  max-height: 600px;
  min-height: 300px;
  box-shadow: 0 4px 12px var(--shadow-color);
  overflow: hidden;
  width: 100%;
  padding-bottom: 12px;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  border-radius: 8px 8px 0 0;
  transition: background 0.3s ease, box-shadow 0.3s ease;

  &:hover {
    background: linear-gradient(135deg, #f0f4f8 0%, #ffffff 100%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  }

  .resources-box {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--grid-gap);
    padding: var(--card-padding);
    overflow-y: auto;

    .s-panel {
      background: white;
      border-radius: var(--card-radius);
      box-shadow: var(--card-shadow);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      overflow: hidden;

      &:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
      }

      &:active {
        transform: translateY(0);
      }
    }
  }

  @media (max-width: 1024px) {
    --grid-gap: 20px;
    --card-padding: 12px;
    --card-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 8px;
    --scrollbar-thumb-color: #c0c0c0;
  }

  @media (max-width: 768px) {
    --grid-gap: 16px;
    --card-padding: 8px;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 6px;
    --scrollbar-thumb-color: #b0b0b0;
  }

  @media (max-width: 480px) {
    --grid-gap: 12px;
    --card-padding: 4px;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --scrollbar-width: 4px;
    --scrollbar-thumb-color: #a0a0a0;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);

  &::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
  }

  &::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
    border-radius: var(--scrollbar-width);
  }

  &::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-color);
    border-radius: var(--scrollbar-width);
    border: 2px solid transparent;
    background-clip: content-box;
  }

  &::-webkit-scrollbar-corner {
    background: transparent;
  }

  .filter-wrapper {
    position: sticky;
    top: 0;
    width: 100%;
    padding: 15px 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 90px;
    box-shadow: 0 1px 6px rgba(192, 192, 192, 0.15);
    backdrop-filter: blur(16px);
    border-radius: 8px;
  }
}

.ads-toggle-btn {
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 8px;
  transition: all 0.3s ease;

  .svg-icon {
    width: 24px;
    height: 24px;
  }

  &:hover {
    transform: scale(1.05);
  }

  &:active {
    transform: scale(0.95);
  }
}